package com.qf.fmall2203.user.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.qf.fmall2203.user.entity.UserAddr;
import com.qf.fmall2203.user.service.IUserAddrService;
import com.qf.fmall2203.utils.ResultVo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/useraddr")
@CrossOrigin
@Slf4j
public class UserAddrController {

    @Autowired
    IUserAddrService userAddrService;

    @GetMapping("/list")
    public ResultVo list(Integer userId){

        final List<UserAddr> data = userAddrService.list(new QueryWrapper<UserAddr>().eq("user_id", userId));

        return ResultVo.ok(data);

    }

}
